DAYTIME_PORT = 13
PACKET_SIZE = 100

DatagramSocket server = new DatagramSocket(DAYTIME_PORT);
println "Daytime Server (UDP Protocol) start at port ${DAYTIME_PORT}"

byte[] buffer = new byte[PACKET_SIZE]
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);

while (true) {
	try {
  		server.receive(packet)
  		//send to client
		Date now = new Date()
		String response = now.toString() + "\r\n";
		byte[] data = response.getBytes("ASCII");
		DatagramPacket outgoing = new DatagramPacket(data, 
				data.length, packet.getAddress(), packet.getPort());
		server.send(outgoing);

	} catch (IOException ex) {
  		println ex
	}      
} // end while

